package com.xique.park.controller.client;


import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.web.page.TableDataInfo;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.client.ClientLaneConfig;
import com.xique.park.service.service.IClientLaneConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗亭通道中间Controller
 * 
 * @author caogq
 * @date 2021-08-02
 */
@Controller
@RequestMapping("/oms/config")
public class ClientLaneConfigController extends BaseController
{
    private String prefix = "oms/config";

    @Autowired
    private IClientLaneConfigService clientLaneConfigService;

    @PreAuthorize(hasPermi = "oms:config:view")
    @GetMapping()
    public String config()
    {
        return prefix + "/config";
    }

    /**
     * 查询岗亭通道中间列表
     */
    @PreAuthorize(hasPermi = "oms:config:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ClientLaneConfig clientLaneConfig)
    {
        startPage();
        List<ClientLaneConfig> list = clientLaneConfigService.selectClientLaneConfigList(clientLaneConfig);
        return getDataTable(list);
    }

//    /**
//     * 导出岗亭通道中间列表
//     */
//    @PreAuthorize(hasPermi = "oms:config:export")
//    @PostMapping("/export")
//    @ResponseBody
//    public AjaxResult export(ClientLaneConfig clientLaneConfig)
//    {
//        List<ClientLaneConfig> list = clientLaneConfigService.selectClientLaneConfigList(clientLaneConfig);
//        ExcelUtil<ClientLaneConfig> util = new ExcelUtil<ClientLaneConfig>(ClientLaneConfig.class);
//        return util.exportExcel(list, "config");
//    }

    /**
     * 新增岗亭通道中间
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存岗亭通道中间
     */
    @PreAuthorize(hasPermi = "oms:config:add")
    @Log(title = "岗亭通道中间", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ClientLaneConfig clientLaneConfig)
    {
        return toAjax(clientLaneConfigService.insertClientLaneConfig(clientLaneConfig));
    }

    /**
     * 修改岗亭通道中间
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ClientLaneConfig clientLaneConfig = clientLaneConfigService.selectClientLaneConfigById(id);
        mmap.put("clientLaneConfig", clientLaneConfig);
        return prefix + "/edit";
    }

    /**
     * 修改保存岗亭通道中间
     */
    @PreAuthorize(hasPermi = "oms:config:edit")
    @Log(title = "岗亭通道中间", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ClientLaneConfig clientLaneConfig)
    {
        return toAjax(clientLaneConfigService.updateClientLaneConfig(clientLaneConfig));
    }

    /**
     * 删除岗亭通道中间
     */
    @PreAuthorize(hasPermi = "oms:config:remove")
    @Log(title = "岗亭通道中间", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(clientLaneConfigService.deleteClientLaneConfigByIds(ids));
    }
}
